package com.study.pattern.controller;


import static com.study.module.MyUtils.waiting;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.study.pattern.observer.usingjdk.CheerLeaderGroup;
import com.study.pattern.observer.vo.LadyData;


@Controller
@RequestMapping("/*")
public class GateController {
	
	final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@RequestMapping("{pattern}")
	public void  HelloPattern(@PathVariable("pattern") String pattern,@RequestParam String params) throws IOException{
		logger.debug("받은 파라미터 : {}",params);
		
		CheerLeaderGroup cheerLeaderGroup = new CheerLeaderGroup();
		cheerLeaderGroup.startChant();
		waiting(8000);
		cheerLeaderGroup.setChanged();
		cheerLeaderGroup.notifyObservers(new LadyData("박아줘요",3000));
		waiting(8000);
		cheerLeaderGroup.setChanged();
		cheerLeaderGroup.notifyObservers(new LadyData("뒤로도 해줘요",1000));
		waiting(4000);
		cheerLeaderGroup.terminateLady();
		
		
//		response.setContentType("text/html; charset=UTF-8");
//		PrintWriter writer = response.getWriter();
//		writer.println(pattern);
//		writer.flush();
	}
}